<!doctype html>
<html>
  <head>
    <title>Intent: Pick</title>
    <script src="/lib/webintents.debug.js"></script>
    <script src="/lib/events.js"></script>
    <script>
     attachEventListener(window, "load", function() {
        var pickImage = document.getElementById("pickImage");
        attachEventListener(pickImage, "click", function() {
          var intent = new Intent();
          intent.action = "http://webintents.org/pick";
          intent.type = "image/*";

          window.navigator.startActivity(intent, intentResponse);

          return false;
        });
  
        var intentResponse = function (intentData) {
          var output = document.getElementById("output");
          output.src = intentData.data[0];
          focus();
        };
      }, false);
    </script>  
  </head>
  <body>
    <h2>Pick an image from a remote service to use in this application</h2>
    <button id="pickImage">Pick an Image</button>
    <h3>Response will appear here:</h3> 
    <img id="output" />

    <h3>Code</h3>
    <pre>var intent = new Intent();
intent.action = "http://webintents.org/pick";
intent.type = "image/*";

window.navigator.startActivity(intent, intentResponse);

var intentResponse = function (intentData) {
  var output = document.getElementById("output");
  output.src = intentData.data[0];
};</pre>
  </body>
</html>

